import * as Cesium from "cesium";
import { App } from "vue";

export type CesiumRef = import("./model").CesiumRef;
export const CESIUM_REF_KEY = Symbol("cesiumRef");

declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    readonly $cesiumRef: CesiumRef;
    readonly $cesium: unknown;
    readonly cesiumRef: CesiumRef;
  }
}

export default {
  install: function (app: App<Element>): void {
    const cr: CesiumRef = {
      viewer: undefined,
      viewerContainer: undefined,
    };
    app.config.globalProperties.$cesiumRef = cr;
    app.config.globalProperties.$cesium = Cesium;
    app.provide<CesiumRef>(CESIUM_REF_KEY, cr);
  },
};
